#include "main/utils.h"
using namespace std;

vector<int> higherTemperature(const vector<int>& vec) {
  stack<int> help_stack;
  vector<int> ret(vec.size(), 0);
  for (int i = 0; i < vec.size(); ++i) {
    while (!help_stack.empty() && vec[i] > vec[help_stack.top()]) {
      int pre_idx = help_stack.top();
      help_stack.pop();
      ret[pre_idx] = i - pre_idx;
    }
    help_stack.push(i);
  }
  return ret;
}

int main() {
  vector<int> vec = {35, 31, 33, 36, 34};
  auto ret = higherTemperature(vec);
  printVec("higherTemperature", ret);

  return 0;
}
